﻿namespace ExamV5.CardInfo
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmPrintCard : Page
    {
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        protected Label labShowUserInfo;
        private PublicFun publicFun_0 = new PublicFun();
        private string string_0 = "";

        private void method_0()
        {
            int count = 0;
            int num2 = 0;
            if (this.string_0.Length > 1)
            {
                this.string_0 = this.string_0.Substring(0, this.string_0.Length - 1);
            }
            this.string_0 = this.publicFun_0.CheckString(this.string_0);
            this.string_0 = "'" + this.string_0.Replace("|", "','") + "'";
            this.labShowUserInfo.Text = "";
            string str = "";
            string selectCommandText = "select a.UserPhoto,a.UserCode,a.UserName,a.UserSex,a.UserSFZH,b.DeptName,c.CardNumber,c.CardStartDate,c.CardEndDate,b.UPID  from UserInfo a,DeptInfo b,CardInfo c  where c.UserCode=a.UserCode and  a.DeptID=b.ID and c.ID in(" + this.string_0 + ") order by c.ID";
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            selectConnection.Open();
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "UserInfo");
            count = dataSet.Tables["UserInfo"].Rows.Count;
            for (int i = 0; i < count; i++)
            {
                num2++;
                if (!(dataSet.Tables["UserInfo"].Rows[i]["UserPhoto"].ToString() == ""))
                {
                    str = "<img align='center'  src='../publicFile/" + dataSet.Tables["UserInfo"].Rows[i]["UserPhoto"].ToString() + "' border=0  Width='104px' Height='122px'>";
                }
                else
                {
                    str = "<img align='center'  src='../publicFile/SysUserImg.gif' border=0  Width='104px' Height='122px'>";
                }
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<table borderColor='#cccccc' cellSpacing='0' cellPadding='0' border='0'  align='center'  width='702' >";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='40'  valign=top><td colspan='4'></td></tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='285'  valign=top align='center'><td colspan='4'>" + str + "</td></tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='35' valign=top>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td align='center' width='230'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td  width='170'  align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["UserName"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td width='230' align='center'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td  width='170' align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["UserSex"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='35'  valign=top><td colspan='4'></td></tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='35' valign=top>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td align='center' width='230'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td  width='170'  align='left'>" + this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='CardSendUnit'", "ParmValue") + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td width='230' align='center'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td  width='170' align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["CardStartDate"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='35'  valign=top><td colspan='4'></td></tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='35' valign=top>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + " <td align='center' width='230'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td  width='170'  align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["CardNumber"].ToString() + "&nbsp;</td>";
                if (this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='CardLotDate'", "ParmValue") == "Y")
                {
                    this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td width='230' align='center'>" + dataSet.Tables["UserInfo"].Rows[i]["CardEndDate"].ToString() + "&nbsp;</td>";
                }
                else
                {
                    this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td width='230' align='center'>&nbsp;</td>";
                }
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td  width='170' align='left'>&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='15'  valign=top><td colspan='4'></td></tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='35' valign=top>";
                if (!(this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='CardSFZH'", "ParmValue") == "Y"))
                {
                    this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td align='center' width='230'>&nbsp;</td>";
                }
                else
                {
                    this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td align='center' width='230'>" + dataSet.Tables["UserInfo"].Rows[i]["UserSFZH"].ToString() + "&nbsp;</td>";
                }
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td  width='170'  align='left'>&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td width='230' align='center'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<td  width='170' align='left'>&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='480'  valign=top><td colspan='4'></td></tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "</table>";
                num2 = i % 2;
                if (num2 != 0)
                {
                    this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<table borderColor='#cccccc' cellSpacing='0' borderColorDark='#ffffff' cellPadding='0' border='0' align='center'><tr  height='31'><td></td></tr></table>";
                }
                else
                {
                    this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<table borderColor='#cccccc' cellSpacing='0' borderColorDark='#ffffff' cellPadding='0' border='0' align='center'><tr  height='31'><td></td></tr></table>";
                }
            }
            adapter.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            this.string_0 = base.Server.UrlDecode(base.Request["UserCode"].ToString());
            if (!((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false))
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
            else
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString + "--打印资格证书";
                if (!base.IsPostBack)
                {
                    this.method_0();
                    base.Response.Write("<script>setTimeout(function(){ if (confirm('确定要打印资格证书吗？')) { window.print();} },2000)</script>");
                }
            }
        }
    }
}

